Published by Timothy Legge on Saturday 18 May 2024 05:08
This year I was invited to the PTS conference in Lisbon as part of the CPAN Security group. Together we have been working on ways to improve the security of the Perl ecosystem. This was a great chance for members of the CPANSec group to meet in person, get to know each other better and discuss some of the items we have been working on lately. Welcome to Nicolas our newest member.
Cyber Resilience Act
One of the major items in the security world is related to the changes coming to Europe as part of the Cyber Resilience Act (CRA). Salve gave a presentation on the updates to the CRA from the past year. The last 12 months has given us a much clearer view of how it affects Open Source projects like Perl and CPAN developers. Open Source developers are less impacted than feared, but if we want our projects to be used it will be important for us to understand what downstream projects and commercial companies will need in order to make use of the tools we make.
Perl and CPAN Modules "need" CVEs
Over the last few months Stig and I have been working through requesting and updating CVE numbers for existing, but older and mostly fixed, vulnerabilities in CPAN modules. During the Summit we presented on this work and the reasons it is important for all vulnerabilities to get published CVEs (whether they are newly discovered issues or issues resolved several years ago).
Our work on this has already shown results. In particular, we have seen that downstream projects (particularly Linux distributions) monitor for CVEs and take note. While CPAN modules often list vulnerability fixes in the Changelog, and CPAN::Audit provides a list of all known vulnerabilities, it is the CVE database that is monitored.
In several cases, it was only after the CVE was published, that a distribution downloaded and released a patched version. Even though that patched module had been released to CPAN months or even years before it was the CVE that got action.
CVE Numbering Authority (CNA)
Stig and I have been researching whether a Perl specific CNA should be established and reviewing the prior work done by the Linux Kernel and Python communities to establish their CNAs.
A Perl specific CNA can be granted the scope for which allows it to grant CVE numbers and publish CVEs. A Perl specific CNA would have more control over the CVEs, which allows it to provide more complete and more accurate information in published CVEs. In addition, because it is (hopefully) working on a smaller number of requests, the CNA can respond quicker.
A number of us met with the Perl Steering Council to discuss whether to set up a CNA and if so what scope should be requested. It was felt that there were good reasons to have a Perl CNA and that it should have scope for both the Perl Interpreter (Perl Core), and CPAN published modules. We will continue to work toward setting up a CNA. There is some upfront work required and we will be determining the expected long term effort. As we go forward we will likely need some assistance, so if you are familiar with or interested in the process, and being a part of it, please reach out.
Linux distributions and CPAN Modules
A few of us met to discuss the state of CPAN modules in Linux distributions. We talked about how the distributions package modules and their approach to patches. The group had representation from Suse, Fedora, Alpinelinux and NixOS. Each distribution faces similar issues:
Tina has worked on a Suse script for package build files and I have worked on Alpinelinux's script for generating package build files. There is a lot of overlap in these scripts and in the scripts/processes used by other distributions. A CPAN module to perform that processing would be helpful. As distributions will likely need to meet the requirements of the CRA, including a Software Bill of Materials (SBOM), helping them meet their existing packaging needs today will help them generate SBOMs in the future.
Patches for vulnerabilities (or functionality) are an ongoing issue for distributions. Each distribution maintains a set of patches for some of their packaged CPAN modules. Patches could be related to packaging, failing tests, functionality improvements or vulnerability fixes. In many cases the patches are available on Request Tracker or Github but have not been implemented in a released version. While some distributions may use the same patch there may also be differences. There was some discussion of how to get these patches into an upstream CPAN release and whether a centralized patch repository of vetted patches makes sense.
The discussion of vulnerability notifications did tend to agree that the CVE database is the usual source of vulnerability notification. If there is no CVE the issue may be missed entirely.
Secure by Default
Secure by default is becoming more of a necessity. Too many times people have been compromised via issues that are the result of insecure configurations. The options are often there, but require the user to specifically make the secure choice.
This is often done to ensure backward compatibility and while it is a good goal it is not generally compatible with secure configurations. Sometimes the responsible decision is to break backward compatibility.
One of the big items worked on by a couple of the CPAN Security members (Nicolas, Breno and Stig) was a patch to make cpanm "Secure by Default" by requiring HTTPS connections only. As this might break some CI pipelines and smokers, etc. Miyagawa is giving it some thought. Hopefully though the PR, or a modified version, will get accepted soon. Feel free to comment on the pull request to show your support (or concerns).
Crypt::OpenSSL::PKCS12
Before PTS Tux had reached out about some changes I had submitted for the module. During PTS, Tux asked whether some improvements could be made to provide information output similar to that outputted by openssl's info command. I took a look at the module and created a patch to provide the information that Tux required. Now that I am back from PTS I need to get that patch ready for submission to the git repo as a PR.
Crypt::OpenSSL::RSA and OpenSSL 3+
The time away from work and other responsibilities (as well as a 7 hour plane ride home) allowed me to work on something I have been planning to look at for quite awhile. Namely creating a patch for Crypt::OpenSSL::RSA to use the updated API calls for OpenSSL 3+ instead of the deprecated functions of older versions.
Anyone who has ever looked at an OpenSSL based XS module and the OpenSSL api in general would likely agree that you need to be in the correct frame of mind, with lots of time to dedicate to it to make progress. I was however, able to submit a draft pull request that updates the API to use non-deprecated functions and get clean builds on Linux, MacOS, Windows, MSSYS and CYGWIN. Todd has said that he will review it soon. My only remaining work (unless changes are needed) is to produce some encrypted data tests to verify the before and after and some performance tests to compare the before and after impacts of using the new API calls.
Organizers
Laurent Boivin, Philippe Bruhat and Breno de Oliveira, Neil Bowers, Barbara Veloso and Teresa Tavares did a fabulous job. From my point of view everything went without a hitch, well planned, well executed. Given that neither of them were in Portugal and Breno did the Lisbon arrangements from Brazil that is amazing and speaks to their abilities to organize. Fantastic work from all involved.
PTS and sponsors
Having been to my first PTS there is no doubt of the importance of the summit and the importance of the sponsors to making it a success. A big shout out to sponsors that contributed to the success of the summit.
Monetary sponsors:
Booking.com, The Perl and Raku Foundation, Deriv, cPanel, Inc, Japan Perl Association, Perl-Services, Simplelists Ltd, Ctrl O Ltd, Findus Internet-OPAC, Harald Joerg, Steven Schubiger.
In kind sponsors:
Fastmail, Grant Street Group, Deft, Procura, Healex GmbH, SUSE, Zoopla.
Published by Paul Johnson on Saturday 18 May 2024 05:07
Sometimes life catches up with you. I've felt that way for the last few years and I'm probably not alone.
During that time the cpancover project has basically just been plodding along, pretty much just working. As new modules were uploaded to CPAN, cpancover would pick them up, calculate the test coverage, and make the results available to be displayed on metacpan, along with detailed output on cpancover.com.
A little while ago I decided it was probably about time that I should update the OS and perl version and libraries and stuff.
And it went terribly.
Last week was the Perl Toolchain Summit. This is the annual event (skipping 2020-2022 of course) where about thirty of the folk who build, maintain and extend much of the Perl infrastructure get together to work on things which really benefit from people being together in the same room, and from setting aside some time to work on these projects with minimal distractions. This overlaps to an extent with core perl work, but the perl core isn't the main focus of the summit. Somehow I've managed join in with most of the events and, for me, it's the most important Perl event on my calendar.
My primary goal at this year's summit was to update the infrastructure around cpancover. For a while now I've been working more and more closely with the metacpan team, initially on displaying coverage results on metacpan, and more recently on working to bring our environments closer together with the idea that cpancover can benefit from the excellent work the metacpan team are doing. This has become more important as I have shown by managed to break a part of my only environment for cpancover.
So, after arriving in Lisbon for this year's PTS, I wanted to spend a time working with the metacpan folk on deciding how to push things forward in this area, and on actually doing so. I had a number of discussions with Joel and with Leo and settled on the way forward. Joel and Leo spent a lot of time working on the metacpan infrastructure, and cpancover became almost like a first customer for the work they are doing, after metacpan itself of course.
But we also looked at how we could fix up cpancover specifically in the short term in a way which would make later migration as simple as possible.
So apart from making these decisions, I also spent time on starting to implement things. I made a couple of Devel::Cover releases during the summit, which were focussed on updating code for infrastructure, as well as incorporating some more modern practices and tooling, such as linters and formatters.
I also made sure Devel::Cover was tested against the latest perl development releases. With a major release just days away this was, I think, the first time for many years where I didn't know there were problems with Devel::Cover on the latest perl development release. But it was good to confirm this. This was also nice in that it left more time for working on other matters.
In cpancover, I have always generated coverage for individual modules in docker containers. This provides a level of control for misbehaving or malicious modules when the tests are run with Devel::Cover. The goal is now to run the main controlling process in a docker container too, to isolate it from the underlying OS. So this work is now started. Unfortunately I didn't manage to finish it, but I did remove all the problems which were stopping me even getting to the point where I could work on it, which feels like a huge success.
So now, I think, it's just a Simple Matter Of Programming to get this done. And then, when the metacpan infrastructure is available we should be able to make use of that to provide more timely results, redundancy, development environments which match what is happening in production, and all that good stuff.
One thing I didn't get around to was looking at some work that Nicholas Clark did and presented at the German Perl Workshop (https://act.yapc.eu/gpw2024/talk/7872) to handle cases where a test suite doesn't even load a module, and the uncovered lines in that module aren't reported. I hope to get to that soon.
But I did manage to spend time talking with many people about work they are doing, covering topics from Test2 to YAMLScript to handling ancient Perl codebases to replacing ppaddr in the perl optree.
One of the things which always feels great about PTS is when you find a bug in a module you're using, and you can chat to the person who wrote the module and they immediately fix the problem. Or vice versa. That happened a few times this year - and it's always nice to get immediate feedback.
And, as usual, I came away with a longer TODO list than I arrived with. But, crucially, I came away unblocked on key design decisions and all the annoying bits of work that just needed to be done before real progress could be made.
I'm really grateful to everyone involved to make this event happen. That includes the organisers, Laurent Boivin, Philippe Bruhat and Breno de Oliveira and likely others behind the scenes. Laurent and Philippe have long been involved in the process and have the knowledge and experience to make the event run smoothly. Breno organised the local details from across an ocean and made sure the event ran with nary a hitch.
I'm also thankful to everyone who attended, often using their own holiday time to do so, and who helped me directly, gave talks or presentations, and generally contributed to the productive environment.
And, of course, none of this would have happened without our sponsors. A big thanks to all of them for their donations, whether as cash or in kind.
Monetary sponsors: Booking.com, The Perl and Raku Foundation, Deriv, cPanel, Inc Japan Perl Association, Perl-Services, Simplelists Ltd, Ctrl O Ltd, Findus Internet-OPAC, Harald Joerg, Steven Schubiger.
In kind sponsors: Fastmail, Grant Street Group, Deft, Procura, Healex GmbH, SUSE, Zoopla.
Published by Ranguard on Saturday 18 May 2024 05:07
Following on from day 1
Joel and I spent some more time working out disk provisioning and then decided to upgrade the nodes in the cluster... this is where the problems started...
I shutdown a node to resize it... and the site went down, no healthy backends was then displayed to all users by Fastly (our CDN) for any content that wasn't in their cache. This is not meant to happen!
We also couldn't connect to Argo (web UI for Kuberneties deployment and a view on the K8's API status) or even the kubectl command line tool.
Starting the node backup (after having upgraded) and all came back. We quickly realised that everything was using Round Robin DNS to all 3 node IP's. There was ` Traefik ` setup but it was tied to those IPs and something was not happy. We then looked at alternative tooling and thought it might be worth using rke2 instead of k3s as the underlying flavour of K8s as this would give us a little more flexibility.
Then things just got worse... we couldn't even get rke2 running... time went by, many options tried and lots of docs / blogs / issues read. We even used other example projects to spin up what seemed to be working Rke2, so the theory was there... rke2 seems want to do things on private IP's, on a specific interface and that seems to clash with Hetzner's way of provisioning private IP's. We also pulled in Robert who uses rke1 currently and he pointed us at a few things to try...
At one point we told the underlying rke2 networking to use wireguard to provide private connection over the public interface. This worked - on a throw away Hetzner box in a test project! Which we threw away - and then could not reproduce again! We proved that we could start things up in a provider other than Hetzner, but that didn't help at this point.
We didn't want to waste more time, so went back to thinking about using k3s, which meant we needed some sort of high availability tooling, ultimately with Hetzner handling this... we could use their Load balancer with health checks... except to have certificates you have to then have Hetzner running the DNS and we already rely on it being CloudFlare for other things.
To say we were disheartened doesn't even come close!
... there is better news on day 4!
Sponsors who make this work possible Monetary sponsors: Booking.com, The Perl and Raku Foundation, Deriv, cPanel, Inc Japan Perl Association, Perl-Services, Simplelists Ltd, Ctrl O Ltd, Findus Internet-OPAC Harald Joerg, Steven Schubiger. In kind sponsors: Fastmail, Grant Street Group, Deft, Procura, Healex GmbH, SUSE, Zoopla.
Published by Ranguard on Saturday 18 May 2024 05:07
Following on from The bad days
We made the decision that our problems in Kubernetes were exactly the sort of thing that should not be distractions to the project. We had been trying to save costs when we choose Hetzner for hosting... especially as we did not know where our ElasticSearch cluster (needing 3x32Gig of ram) was going to live. The great news is last week ElasticSeach agreed to host this for us, which really is a game changer.
With this in mind, we reviewed hosting again... Digital Ocean (DO) provides a fully managed Kubernetes control plane, with high availability load balancer, Postgres Database integration and storage options e.g. we can focus on deploying to it and not managing it.
And a few hours later Joel and I had updated all our manifests to work on DO. Joel setup nginx to do internal load balancing, we started the web front end and tested stopping a node. Everything worked! We switched over the Fastly setup to use this new cluster as production... so far all has been good.
As I went on to convert more pieces while Joel setup nfs server to share volumes between pods on different nodes. We then started the setup for grep.metacpan.org. Which we kicked of the initial setup at 8:40pm and then Joel remembered he had to get pasta de nata for his family before the best shop shut!
Grep.metacpan.org has a large repo it clones and this took quite a while, but by the next morning we were able to make it live.
So... we as MetaCPAN are in a much stronger position, using a managed service, and with more people understanding the setup. There is more work to do, but we achieved a lot in the few days we were together.. something that would have taken weeks with any other approach. The existence of the PTS events makes it possible.
Sponsors who make this possible Monetary sponsors: Booking.com, The Perl and Raku Foundation, Deriv, cPanel, Inc Japan Perl Association, Perl-Services, Simplelists Ltd, Ctrl O Ltd, Findus Internet-OPAC Harald Joerg, Steven Schubiger. In kind sponsors: Fastmail, Grant Street Group, Deft, Procura, Healex GmbH, SUSE, Zoopla.
Published by Anonymous on Saturday 18 May 2024 04:16
I just started learning Perl. I attempted to make a simple calculator that takes input from the command line. Input: 5 * 10
. Output: 50
. But instead, it just prints 5. Here's the code:
#!usr/bin/perl
use strict;
use warnings;
my $op = $ARGV[1];
my $outpt = eval("return $ARGV[0]"."$op"."$ARGV[2]");
print "$outpt"."\n";
Any advice would be appreciated.
I tried to input all as one string instead, but that resulted in terminal output no matches found. How should I fix the error.
Published by mauke on Friday 17 May 2024 21:48
perlfunc/stat: fix description of S_ENFMT and S_IFMT S_ENFMT properly belongs to the group of permission bits (like setuid/setgid), not file types. On systems that have it (like AIX), it can be set/cleared with chmod(). (In fact, it usually shares its value with S_ISGID because enforced locking is signaled by the combination of a non-executable file with the setgid bit set.) S_IFMT($mode) directly gives you one of the file types (S_IFREG, S_IFDIR, etc). You don't need to bit-and it further (especially not with the S_IS* functions), contrary to what the comment claims. (The confusion likely stems from the C side of things, where you'd do `mode & S_IFMT` to extract the file type from the mode bits, leading to code like `(mode & S_IFMT) == S_IFDIR`. But even then you could write `S_ISDIR(mode)` without any bit mask trickery.) Most of the symbols in the "S_IF* constants" section don't start with "S_IF", so change to "S_I* constants" everywhere. Most of the symbols in the "S_IF* functions" section don't start with "S_IF" (with the sole exception of S_IFMT, which is only a function in Perl; the C macro is a constant). (Historical note: This section label used to make more sense because it documented S_IFMODE and S_IFMT functions, but the former was just a typo for S_IMODE.)
Published by rwp0 on Friday 17 May 2024 13:45
`perlbook.pod`: Fix few leftovers The "Safari" reference redirects to oreilly.com anyway. It is also renamed: https://en.wikipedia.org/wiki/O%27Reilly_Media#O'Reilly_Online_Learning_(formerly_Safari_Books_Online)
Published by Grinnz on Friday 17 May 2024 13:42
perlsub: correct confusing references to local in my docs The docs for lexical variable declarations referenced 'local' as a mechanism to declare global variables in a couple instances, which is incorrect. 'local' only localizes global variables, it doesn't create or declare them in the common case where strict 'vars' is in effect.
Published by /u/oalders on Friday 17 May 2024 00:06
submitted by /u/oalders [link] [comments] |
Published by Saif on Thursday 16 May 2024 21:52
The paella must be possibly the worst national dish ever created, I thought to myself as I looked at the charred remains in my pan. It is as if the mind of some ancient Spanish conquistador, returned from his conquests abroad feeling hungry and unfulfilled, dreamt of bringing byriani to Spain, but in the midst of pillaging had forgotten to take culinary notes.
"How difficult can it be, Jose?" the weary warrior muses,
"Yeah, yeah, its just rice and meat, innit", says his Catalan colleague coming from the Spanish equivalent of Birmingham.
"We could use something flavourless, amorphous and chewy, like mussels, instead of meat",
"Whoaaah, nice,",
"And langoustines...",
"langa-what?",
"I know, right? Just throw them all in, don't bother shelling them",
"Raphael has some tomatoes he doesn't need for pelting passing pedestrians",
"Ahh...the flavours", fanning the flames as the smell of their concoction cooking brings back fond memories of far-away burning villages.
As I proudly presented my still smouldering efforts on the table, I am met with quizzical glances.
"What is it?" asked Mrs Saif, "I mean I can see what it is, but what is meant to be?",
"Its Spanish! Paella!", I exclaimed, "It's what Nadal, Ballesteros, and Ronaldo eat, guys. Come on, tuck in!",
The kids were not too sure, "Looks like your byriani" said one, encouragingly.
"Ronaldo is Portuguese," said another hoping to distract while passing her food to the dog who knew better.
"Look, why don't we order Mexican" said Mrs Saif kindly, "and you can try something you are goo.. err.. not so bad at."
Failure, I am used to. Under appreciation, I accept as the condemned accepts the noose. If I can divert my attention to coding instead of cooking, I may perhaps have less cause for despondency. But for me, the two streams of activity, cooking or coding, have the same triggers, and very often the same outcomes. Some one says: "You can't cook", outcome: paella. "You can't do this in Perl", outcome: more burnt offerings, sacrificing time and sanity, yielding an unrecognisable, unconsumable concoction for presentation to a community that never wanted it in the first place.
So when one person on Reddit presented a gist to use bash
, ncal
and Perl to create a week counting calendar on a terminal,
I thought, hey this could be done in Perl alone.
What's the point?
Here-in lies the problem with the irresponsible, belligerent coder, unsatisfied with mere re-implementation of another's code, who has to add his own flavours into the profusion of existing successful recipes. After all, MetaCPAN has no shortage of Calendar Modules,
including Manwar's collection of excellent exotic calendars. EDIT: In fact Dave Cross' Calendar::Simple
has an example which does exactly this.
I have started yet another project, this time a Calendar Application for the Terminal,
which will (eventually) be interactive, customisable, use terminal colours for highlighting, allow adding and removing of events, will import, export and use standard .ics
files, and create crontab
lines. Or it might end up an exercise that once again reveals how inadequacies overcome aspirations.
Similar things exist (CalCurses, uses curses library) and
(khal in Python) as well as cal
and ncal
, for those interested in such tools. Of course, I know my limitations, and this project will be Pure Perl. Pure Madness. Of course, if someone gets the title of this blog, somehow, it will prove to me that there are such other mad people around.
Published on Thursday 16 May 2024 19:00
The Perl and Raku Conference (now in its 26th year) would not exist without sponsors. Above, you’ll see a screen shot from Curtis Poe’s Perl’s new object-oriented syntax is coming, but what’s next? talk at last year’s conference in Toronto. You may be wondering how you can add your organization’s logo to this year’s list. In the spirit of transparency, we are making our sponsorship prospectus public. Please share this article freely with friends, colleagues and decision makers so that we can reach as many new sponsors as possible.
This year the Perl and Raku Conference will be held in Las Vegas, Nevada on June 24-28, 2024. Conferences such as this provide tangible benefits to organizations which use Perl. Aside from the transfer of knowledge which attendees bring back to their place of work, on-site hackathons also contribute to the growth and maintenance of the software stack which so many companies have come to rely on. In 2022, for example, the hackathon focused on modernizing and improving support for Perl across various editors, allowing Perl developers to be even more productive than they have been in the past.
There are still opportunities to support this important, grassroots Open Source Software event. Events like these largely depend on sponsors in order to thrive.
This year, we are looking for corporate donations to offset the costs of feeding conference attendees. Each of these sponsorship opportunities comes with the following:
Sponsor a catered breakfast during one of the conference days
Sponsorship commitment: $3,500
Sponsor a catered snack break during one of the conference days.
Sponsorship commitment: $3,000
Sponsor a coffee break during one of the conference days.
Sponsorship commitment: $2,500
Please do let me know at what level you might be interested in contributing and we can begin the process of getting you involved in this very special event.
In order to get your logo on the “step and repeat” banner we would need to have finalized sponsorship and received logo assets by June 1st, so we’d love to help you start the process as soon as you’re ready.
For any questions or to begin the sponsorship process, please contact me via olaf@wundersolutions.com. I’ll be happy to answer any questions and walk you through the process. If you’d like to discuss sponsorship options which are greater or smaller than the offerings listed, I can also work with you on that. If you’re not ready to sponsor this event but would like to be included in future mailings, please reach out to me via email as well. I look forward to hearing from you!
In 2024 we expect to host over 100 attendees, but there is a hard cap of 150. If you’re thinking of attending, it’s best to secure your ticket soon.
Fix HTTP and Books links Update some obsolete Perl book URLs. Convert some HTTP links to HTTPS. Wrap links in `L<>`. Committer: Resolve merge conflicts in pod/perllocale.pod. For: https://github.com/Perl/perl5/pull/22186
Published by khwilliamson on Wednesday 15 May 2024 23:01
perllocale: Update for 5.40 state of affairs This makes corrections, and additions
Published by Bob Lied on Wednesday 15 May 2024 14:08
You and I have memories, longer than the road that stretches out ahead. Remember when refactoring was a Big Deal? Let's do some of that this week.
You are given an array of distinct integers, @ints.
Write a script to distribute the elements as
described below:
1) Put the 1st element of the given array to
a new array @arr1.
2) Put the 2nd element of the given array to
a new array @arr2.
Once you have one element in each arrays,
@arr1 and @arr2, then follow the rule below:
If the last element of the array @arr1 is greater
than the last element of the array @arr2, then
add the first element of the given array to @arr1,
otherwise to the array @arr2.
When done distribution, return the concatenated
arrays, @arr1 and @arr2.
@ints = (2, 1, 3, 4, 5)
Output: (2, 3, 4, 5, 1)
@arr1 = (2)
@arr2 = (1)
@arr1
is greater than the last element of @arr2
, so add 3 to @arr1 = (2, 3)
.@arr1
is greater than the last element of @arr2
, add 4 to @arr1 = (2, 3, 4)
@arr1
is again greater than the last element of @arr2
, add 5 to @arr1 = (2, 3, 4, 5)
@arr1 = (2, 3, 4, 5)
and @arr2 = (1)
(2, 3, 4, 5, 1)
.That's a very prescriptive specification and example. We could hardly do anything else.
sub distElem(@ints)
{
my @arr1 = shift @ints;
my @arr2 = shift @ints;
while ( defined(my $n = shift @ints) )
{
if ( $arr1[-1] > $arr2[-1] ) {
push @arr1, $n;
} else {
push @arr2, $n;
}
}
return [ @arr1, @arr2 ];
}
Perl notes:
@ints
array by shifting off one element at a time. Numbers could be zero, and we don't want that interpreted as false
, so the accurate check is to look for the undef
when the array becomes empty.It irks me to have the two variables named arr1
and arr2
. What is this, BASIC? It's a list of two arrays, so let's do that refactoring.
sub distElem(@ints)
{
my @arr = ( [shift @ints], [shift @ints] );
while ( defined(my $n = shift @ints) )
{
if ( $arr[0][-1] > $arr2[1][-1] ) {
push @{$arr[0]}, $n;
} else {
push @{$arr[1]}, $n;
}
}
return [ $arr[0]->@*, $arr[1]->@* ];
}
Perl notes:
push
needs to be an array, so the @{...}
turns the reference into an array. In the return statement, I use newer-style postfix de-referencing.Now I'm annoyed by that if
statement. We only have to choose between 0 and 1, and we have a condition that will be either true or false. Zero, one; false, true. Po-tay-to, po-tah-to. Let's use that condition to make an index.
sub distElem(@ints)
{
my @arr = ( [shift @ints], [shift @ints] );
while ( defined(my $n = shift @ints) )
{
my $which = ( $arr[0][-1] <= $arr[1][-1] );
push @{$arr[$which]}, $n;
}
return [ $arr[0]->@*, $arr[1->@*} ];
}
Perl notes:
>
to <=
so that the array order is the same.Introducing the $which
variable seems arbitrary. Let's put that in-line.
sub distElem(@ints)
{
my @arr = ( [shift @ints], [shift @ints] );
while ( defined(my $n = shift @ints) )
{
push @{$arr[ $arr[0][-1] <= $arr[1][-1 ]}, $n;
}
return [ $arr[0]->@*, $arr[1->@*} ];
}
Why am I chewing up the @ints
array with shifts? Let's just iterate over it.
sub distElem(@ints)
{
my @arr = ( [shift @ints], [shift @ints] );
push @{$arr[ $arr[0][-1] <= $arr[1][-1 ]}, $_ for @ints;
return [ $arr[0]->@*, $arr[1->@*} ];
}
One last thing: can we make it do reasonable things when the @ints
array has 0 or 1 elements? Currently, that inital shift to initialize @arr
would put an undef
value into the lists. Let's account for the possibility.
sub distElem(@ints)
{
my @arr = ( [ (shift @ints) // () ], [ (shift @ints) // () ] );
push @{$arr[ ( $arr[0][-1] <= $arr[1][-1] ) ]}, $_ for @ints;
return [ $arr[0]->@*, $arr[1]->@* ];
}
Perl notes:
shift
on an empty array will yield undef
, but we want an empty list in that case.//
operator is really useful for checking defined-ness. In the old days, code was littered with if (defined(...))
tests.That was the process I used to get from 11 lines to 3. Of course, there were unit tests executed at every step. The final code, including tests is in GitHub
We're happy to confirm the venue and date of this year's London Perl & Raku Workshop.
This year's workshop will be held at The Trampery, at Old Street. A dedicated modern event space in central London. We have hired both The Ballroom and The Library; allowing us to run a main track for up to 160 attendees, and second smaller track for up to 35 attendees.
The Trampery in Old Street is located a two minute walk from the Northern Line's Old Street tube station in central London. The Northern Line has stops at most of the major train stations in London, or trivial links to others, so we recommend taking the tube to get to the venue.
If you haven't already, please signup and submit talks using the official workshop site: https://act.yapc.eu/lpw2024/
Thanks to this year's sponsors, without whom LPW would not happen:
If you would like to sponsor LPW then please have a look at the options here: https://act.yapc.eu/lpw2024/sponsoring.html
Published by /u/SamuchRacoon on Monday 13 May 2024 13:03
I’m sorry if the text is strange, but I cannot upload it with my laptop.
I want to repeat a process for every key in a hash, with numeric keys. So there are 3 possibilities, with 3 if, and each one compares the value of the index of an array, so that if that position eq to "sp", "sp2" or "sp3" it will search in a document some value so then it can be printed.
It doesn´t work and every times gives me only one value, i would like to get the values that correspond with the hash.
For example the hash could be %grupos=(1,'A',2,'G',3,'J')
and the array @ hibridaciones=("sp","sp2",sp3")
The document .txt (simplified) is:
HS0.32
CS0,77
CD0.62
CT0,59
C10,77
C20,62
C30,59
OS0.73
OD0,6
O10,73
O20,6
NS0.75
The code is:
@hibridaciones=("sp","sp2",sp3") %grupos=(1,'A',2,'G',3,'J') open (covalencia,"<", "cov.txt") or die "$!\n"; print keys %grupos; keys %grupos; foreach my $z (keys %grupos) { print "\n$z\n"; if (@hibridaciones[my $z-1] eq "sp") { while (my $line = <covalencia>) { if ( $line=~/^C1/) { $line =~s/C1//; $radio=$line; print "\n$radio"; } } } if (@hibridaciones[my $z-1] eq "sp2") { while (my $line = <covalencia>) { if ($line=~/^C2/) { $line =~s/C2//; $radio=$line; print "\n$radio"; } } } if (@hibridaciones[my $z-1] eq "sp3") { while (my $line = <covalencia>) { if ($line=~/^C3/) { $line =~s/C3//; $radio=$line; print "\n$radio"; } } } } close (covalencia);@hibridaciones=("sp","sp2",sp3") %grupos=(1,'A',2,'G',3,'J') open (covalencia,"<", "cov.txt") or die "$!\n"; print keys %grupos; keys %grupos; foreach my $z (keys %grupos) { print "\n$z\n"; if (@hibridaciones[my $z-1] eq "sp") { while (my $line = <covalencia>) { if ( $line=~/^C1/) { $line =~s/C1//; $radio=$line; print "\n$radio"; } } } if (@hibridaciones[my $z-1] eq "sp2") { while (my $line = <covalencia>) { if ($line=~/^C2/) { $line =~s/C2//; $radio=$line; print "\n$radio"; } } } if (@hibridaciones[my $z-1] eq "sp3") { while (my $line = <covalencia>) { if ($line=~/^C3/) { $line =~s/C3//; $radio=$line; print "\n$radio"; } } } } close (covalencia);
Originally published at Perl Weekly 668
Hi there,
The latest Perl Steering Council weekly updates about the good progress in preparation of release of Perl v5.40. I can't wait to get my hand dirty with the new features.
London Perl Workshop is making good progress thanks to the hard work of Lee Johnson. As per the official website, we now have a Diamond Sponsor. I am hoping venue would be finalised soon. I would urge all Perl fans to register your interest in the event so that the organiser can plan the event better.
The upconing event, The Perl and Raku Conference in Las Vegas, is in demand. I get to hear a lot of preparation is underway to make it memorable experience for all attendees. I am going to miss the fun, unfortunately. I hope to join you all online if it is available.
Last but not least, you take extra care of yourself and your loved ones. Enjoy and celebrate Perl as always.
--
Your editor: Mohammad Sajid Anwar.
Good news is shared that Perl v5.40 is likely to be released on time in May. Hurray !!!
Nice to hear the work done by CPANSec Group. We are happy to see members are actively working on the security aspect.
Interesting topic brought to the discussion table with regard to the use of DBIx::Class and it's family. It is thorough discussion and not just scratch the surface.
Calendar is one topic that has been discussed plenty of times and we have loads of different implmentation available on CPAN. Saif is bringing a new flavour, go check it out.
The Weekly Challenge by Mohammad Sajid Anwar will help you step out of your comfort-zone. We pick one champion at the end of the month from among all of the contributors during the month.
Welcome to a new week with a couple of fun tasks "Bitwise OR" and "Distribute Elements". If you are new to the weekly challenge then why not join us and have fun every week. For more information, please read the FAQ.
Enjoy a quick recap of last week's contributions by Team PWC dealing with the "Magic Number" and "Number Game" tasks in Perl and Raku. You will find plenty of solutions to keep you busy.
A new CPAN module introduced Data::Show. Time to explore more about it. Thanks for sharing.
Smart match of Raku is really cool. The post shares the use of smart match. Highly recommended.
I love the varieties of different level of solutions. Start with simple and then move upward to make it more elegant. Great work.
Ever wanted to implement Z- operator in Perl? Well it is already done and shared. Just check it out yourself.
My personal favourite PDL is in the game again. Thanks for sharing knowledge with us.
Reduction operator of Raku is one of the most powerful operator. Please checkout the post to see how it can be used.
Handy Raku REPL is showing off the power. You really don't want to skip it. Thanks for sharing.
Another Raku fan talking about rotor of Raku. I wonder if this can be reproduced this in Perl?
Master of one-liner in Perl, sharing experimental for_list. Time to explore more about it soon. Well done and keep it up.
Task analysis is the top level and very engaging. Thanks for sharing the knowledge with us.
Short and compact solutions in Perl, Raku and Python. Plenty to keep you busy. You get to listen to music as bonus.
Peter finally gave in and created one-liner in Perl. It is so much fun to see how powerful it is.
Well documented solutions with smart use of CPAN module. Well done, keep it up great work.
I noticed the zip6 is mentioned in the blog post but in code, pairwise is used. Interesting, zip6 is new to me, though.
One liner in Python and PostScript. Bonus for this week is the introduction to Crystal. Keep it up great work.
Is it possible to have multiple return types in Python? I didn't know that, I liked how it is perfectly used here. Thanks for sharing the magic with us.
Great CPAN modules released last week;
StackOverflow Perl report.
You joined the Perl Weekly to get weekly e-mails about the Perl programming language and related topics.
Want to see more? See the archives of all the issues.
Not yet subscribed to the newsletter? Join us free of charge!
(C) Copyright Gabor Szabo
The articles are copyright the respective authors.
Published by /u/niceperl on Sunday 12 May 2024 07:43
Published by Unknown on Sunday 12 May 2024 09:43
These are the five most rated questions at Stack Overflow last week.
Between brackets: [question score / answers count]
Build date: 2024-05-12 07:32:36 GMT
Each week Mohammad S. Anwar sends out The Weekly Challenge, a chance for all of us to come up with solutions to two weekly tasks. My solutions are written in Python first, and then converted to Perl. It's a great way for us all to practice some coding.
You are given two arrays of integers of same size, @x
and @y
.
Write a script to find the magic number that when added to each elements of one of the array gives the second array. Elements order is not important.
For input via the command line, I take a list of integers and then split the list in two. Calling the Python function directly takes two list.
For this task I numerically sort the two lists x
and y
. I then calculate the different between the first values in each list, and store this as diff
.
I then loop through each position in the list to ensure the difference between the integers in that position in each list is diff
. If it isn't, I exit early.
def magic_number(x: list, y: list) -> int | None:
x = sorted(x)
y = sorted(y)
diff = y[0] - x[0]
for i in range(len(x)):
if y[i] - x[i] != diff:
return None
return diff
$ ./ch-1.py 3 7 5 9 5 7
2
$ ./ch-1.py 1 2 1 5 4 4
3
$ ./ch-1.py 2 5
3
You are given an array of integers, @ints
, with even number of elements.
Write a script to create a new array made up of elements of the given array. Pick the two smallest integers and add it to new array in decreasing order i.e. high to low. Keep doing until the given array is empty.
This is relatively straight forward, so doesn't need much explanation. For this task, I sort the list and then swap each pairs of numbers (1st and 2nd, 3rd and 4th, etc).
Both Python and Perl support the x, y = y, x
syntax to swap numbers without using a temporary value.
def numbers_game(ints: list) -> list:
ints = sorted(ints)
for i in range(0, len(ints), 2):
ints[i], ints[i+1], = ints[i+1], ints[i]
return ints
$ ./ch-2.py 2 5 3 4
(3, 2, 5, 4)
$ ./ch-2.py 9 4 1 3 6 4 6 1
(1, 1, 4, 3, 6, 4, 9, 6)
$ ./ch-2.py 1 2 2 3
(2, 1, 3, 2)
Published by /u/Adriaaaaaaaan on Saturday 11 May 2024 11:27
submitted by /u/Adriaaaaaaaan [link] [comments] |
Published by Makoto Nozaki on Thursday 09 May 2024 19:21
TL;DR We just finished intern selection for this year’s Outreachy program. We got more projects and more applicants than the previous years, which made the selection hard in a good way.
Continuing our annual tradition, The Perl and Raku foundation is involved in the Outreachy program which provides internships to people subject to systemic bias and impacted by underrepresentation.
We have just finished the intern selection process, which turned out to be harder compared to the previous years. I’ll explain the reasons below.
Each year, we call for project ideas from the Perl/Raku community. Project proposer is required to commit to mentoring an intern from May to August. Given the significant commitment involved, it’s not uncommon for us to find suitable projects.
Fortunately, this year, we got two promising project proposals. The Foundation’s financial situation did not allow us to sponsor both projects, so we had to make the tough decision to support only one project.
After careful consideration, the Board has elected to sponsor Open Food Fact’s Perl project, titled “Extend Open Food Facts to enable food manufacturers to open data and improve food product quality.”
Having more projects means we were able to attract more intern candidates. Across the two projects, more than 50 people showed interest and initiated contributions. Among them, 21 individuals actually created pull requests before the selection process.
Needless to say, it's hard work for the mentors to help dozens of candidates. They taught these intern candidates how to code and guided them through creating pull requests. On the applicants’ side, I am amazed that they worked hard to learn Perl and became proficient enough to create pull requests and make real improvements to the systems.
After the contribution process, we got an application from 14 people. It was obviously hard for the mentors to select one from so many good applicants. In the next post, Stéphane Gigandet will introduce our new intern to the community.
I wish all the best to the mentors, Stéphane and Alex, and our new intern.
"In the journey to understand Perl better, I wanted to know what are its most wide applications, one of them being a web scraper. It's because Perl's strong support for regular expressions and built-in text manipulation functions make it well-suited for tasks like web scraping, where parsing and transforming text are essential. I took inspiration from various web scraping projects available on the internet to gain insights into the process and developed a lyrics scraper."
"I'm currently diving into Perl, and I see this as a fantastic chance to enrich my coding skills. I've thoroughly enjoyed immersing myself in it and have had the opportunity to explore various technologies like Docker and more."
"I have had the opportunity to experience Perl firsthand and have come to appreciate its significance in web development, on which I have worked. During my second year, I was searching for popular languages in backend development and found out about Perl, whose syntax was somewhat like C and Python. I didn't have any previous experience working with Perl, but now I have gained a deep understanding of its importance and impact on backend development and data processing."
"In this pull request, I made a significant stride in improving the quality and maintainability of our Perl codebase by integrating Perl::Critic, a powerful static code analysis tool."
"I've learned a whole lot about Perl and some of its frameworks such as Dancer2 (a surprisingly simple framework I've come to fall in love with)."
Welcome to “What’s new on CPAN”, a curated look at last month’s new CPAN uploads for your reading and programming pleasure. Enjoy!
Published by alh on Monday 06 May 2024 19:42
Tony writes:
``` [Hours] [Activity] 2024/02/01 Thursday
2.50
2024/02/02 Friday 0.72 #21915 review, testing, comments
0.97
2024/02/05 Monday 0.25 github notifications 0.08 #21885 review updates and approve 0.57 #21920 review and comment 0.08 #21921 review and approve 0.12 #21923 review and approve 0.08 #21924 review and approve 0.08 #21926 review and approve 0.67 #21925 review and comments
3.93
2024/02/06 Tuesday 0.23 #21925 comment 0.52 review coverity scan report, reply to email from jkeenan 0.27 #21927 review and comment 0.08 #21928 review and approve
1.18
2024/02/07 Wednesday 0.25 github notifications 0.52 #21935 review, existing comments need addressing
2.89
2024/02/08 Thursday 0.40 #21927 review and approve 0.23 #21935 review, check each comment has been addressed, approve 0.45 #21937 review and approve 0.15 #21938 review and comment 0.10 #21939 review and approve 0.13 #21941 review and approve 0.10 #21942 review and approve 0.08 #21943 review and approve 0.07 #21945 review and approve 0.17 #21877 look into CI failures, think I found problem, push probable fix 0.18 #21927 make a change to improve pad_add_name_pvn() docs, testing, push for CI 2.20 #21877 performance test on cygwin, try to work up a
4.26
2024/02/12 Monday 0.60 #18606 fix minor issue pointed out by mauke, testing 0.40 github notifications 0.08 #21872 review latest changes and approve 0.08 #21920 review latest changes and approve 1.48 #21877 debugging test 0.30 #21524 comment on downstream ticket
3.21
2024/02/13 Tuesday 0.35 #21915 review, brief comment 0.25 #21983 review and approve 0.03 #21233 close 0.28 #21878 comment 0.08 #21927 check CI results and make PR 21984 0.63 #21877 debug failing CI 0.27 #21984 follow-up 0.58 #21982 review, testing, comments
2.79
2024/02/14 Wednesday 1.83 #21958 testing, finally reproduce, debugging and comment 0.08 #21987 review discussion and briefly comment 0.08 #21984 apply to blead 0.22 #21977 review and approve 0.12 #21988 review and approve 0.15 #21990 review and approve 0.82 #21550 probable fix, build tests 0.38 coverity scan follow-up 1.27 #21829/#21558 (related to 21550) debugging
5.60
2024/02/15 Thursday 0.15 github notifications 0.08 #21915 review updates and approve 2.17 #21958 debugging, research, long comment 0.58 #21958 testing, follow-up
3.10
2024/02/19 Monday 0.88 #21161 review comment and reply, minor change, testing, force push 0.23 #22001 review and comment 0.30 #22002 review and comment 0.12 #22004 review and comment 0.28 #22005 review and approve 0.32 #21993 testing, review changes 1.95 #21661 review comments on PR and fixes, review code and
4.08
2024/02/20 Tuesday 0.35 github notifications 0.08 #22010 review and approve 0.08 #22007 review and approve with comment 0.60 #22006 review, research and approve with comment 0.08 #21989 review and approve 0.58 #21996 review, testing, comment 0.22 #22009 review and approve 0.50 #21925 review latest updates and approve
3.54
2024/02/21 Wednesday 0.18 #22011 fixes 0.80 #21683 refactoring
2.78
2024/02/22 Thursday 0.38 #22007 review and comment 0.70 #21161 apply to blead, perldelta as PR22017 1.75 smoke report checks: testing win32 gcc failures 0.27 #22007 review updates and approve
4.25
2024/02/26 Monday 2.10 look over smoke reports, debug PERLIO=stdio failure on mac
3.48
2024/02/27 Tuesday 0.08 #22029 review and apply to blead 0.27 #22024 review and approve 0.33 #22026 review and approve 0.08 #22027 review and approve 0.10 #22028 review and approve 0.08 #22030 review and comment, conditionally approve 0.25 #22033 review, comments and approve 0.08 #22034 review and approve 0.17 #22035 review and comment
2.22
2024/02/28 Wednesday 0.38 github notifications 0.52 #22040 review discussion, research and comment 0.13 #22043 review and approve 0.12 #22044 review and approve 0.72 #22045 review, research, comment and approve 0.13 #22046 review, research and approve
3.55
2024/02/29 Thursday 0.15 #21966 review update and approve 1.18 #21877 debugging
1.46
Which I calculate is 55.79 hours.
Approximately 70 tickets were reviewed or worked on, and 5 patches were applied. ```
Published by Lee J on Monday 06 May 2024 14:39
The London Perl & Raku Workshop (LPW) will take place this year on Saturday 26th October and you are encouraged to submit your talk proposals now. The venue is in final stages of being confirmed - it will be in central London (UK).
We'd also like to announce our CFP. We welcome proposals relating to Perl 5, Raku, other languages, and supporting technologies. We may even have space for a couple of talks entirely tangential as we are close to finalising the venue (very central London) and should have room for two tracks.
Talks may be long (40mins), short (20 mins), or very short (aka lightning, 5 mins) but we would prefer talks to be on the shorter side and will likely prioritise 20min talks. We would also be pleased to accept proposals for tutorials and discussions. The deadline for submissions is 30th September.
We would really like to have more first time speakers. If you’d like help with a talk proposal, and/or the talk itself, let us know - we’ve got people happy to be your talk buddy!
Register (it's free!) and submit your talk on the workshop site.
We would also like to make a call for sponsors - does your company want to support the workshop? By sponsoring LPW you can demonstrate your support for the Perl and/or Raku languages and nurture your relationship with the local developer community. Much more information can be found on the workshop site along with a sponsor prospectus.
As well as the benefits as listed on the aforementioned page, sponsors will all feature in blog posts, news posts, social media posts.
That starts right now, with our first sponsors who have already generously sponsored the workshop:
With thanks from The London Perl & Raku Workshop 2024 organising team.
Published by Unknown on Saturday 04 May 2024 22:46
Published by Makoto Nozaki on Friday 03 May 2024 19:49
I am pleased to announce that The Perl and Raku Foundation sponsored the Perl Toolchain Summit 2024 as a Platinum Sponsor.
The Perl Toolchain Summit (PTS) is an annual event where they bring together the volunteers who work on the tools and modules at the heart of Perl and the CPAN ecosystem. The PTS gives them 4 days to work together on these systems, with all their fellow volunteers to hand.
The event successfully concluded in Lisbon, Portugal at the end of April 2024.
If you or your company is willing to help the future PTS events, you can get in touch with the PTS team. Alternatively, you can make a donation to The Perl and Raku Foundation, which is a 501(c)(3) organization.
Published by perlancar on Wednesday 01 May 2024 02:38
dist | author | abstract | date |
---|---|---|---|
AI-Ollama-Client | CORION | Client for AI::Ollama | 2024-04-05T09:15:33 |
Acme-CPANModules-BPOM-FoodRegistration | PERLANCAR | List of modules and utilities related to Food Registration at BPOM | 2024-04-27T00:06:16 |
Acme-CPANModules-JSONVariants | PERLANCAR | List of JSON variants/extensions | 2024-04-29T00:05:46 |
Alien-NLOpt | DJERIUS | Build and Install the NLOpt library | 2024-04-28T00:59:11 |
Alien-onnxruntime | EGOR | Discover or download and install onnxruntime (ONNX Runtime is a cross-platform inference and training machine-learning accelerator.) | 2024-04-17T22:03:45 |
AnyEvent-I3X-Workspace-OnDemand | WATERKIP | An I3 workspace loader | 2024-04-12T18:33:21 |
App-papersway | SPWHITTON | PaperWM-like window management for Sway/i3wm | 2024-04-12T08:18:00 |
App-sort_by_comparer | PERLANCAR | Sort lines of text by a Comparer module | 2024-04-16T00:06:00 |
App-sort_by_example | PERLANCAR | Sort lines of text by example | 2024-04-20T00:05:10 |
App-sort_by_sorter | PERLANCAR | Sort lines of text by a Sorter module | 2024-04-17T00:05:42 |
App-sort_by_sortkey | PERLANCAR | Sort lines of text by a SortKey module | 2024-04-24T00:06:38 |
Arithmetic-PaperAndPencil | JFORGET | simulating paper and pencil techniques for basic arithmetic operations | 2024-04-22T19:57:44 |
Bencher-Scenario-ExceptionHandling | PERLANCAR | Benchmark various ways to do exception handling in Perl | 2024-04-13T00:05:36 |
CPAN-Requirements-Dynamic | LEONT | Dynamic prerequisites in meta files | 2024-04-27T15:17:57 |
CSAF | GDT | Common Security Advisory Framework | 2024-04-23T21:49:42 |
CXC-DB-DDL | DJERIUS | DDL for table creation, based on SQL::Translator::Schema | 2024-04-04T16:24:13 |
Captcha-Stateless-Text | HIGHTOWE | stateless, text-based CAPTCHAs | 2024-04-17T21:19:21 |
Carp-Object | DAMI | a replacement for Carp or Carp::Clan, object-oriented | 2024-04-28T17:58:22 |
Carp-Patch-OutputToBrowser | PERLANCAR | Output stacktrace to browser as HTML instead of returning it | 2024-04-25T00:05:19 |
Catalyst-Plugin-Flash | ARISTOTLE | put values on the stash of the next request | 2024-04-09T05:06:19 |
Comparer-date_in_text | PERLANCAR | Compare date found in text (or text asciibetically, if no date is found) | 2024-04-18T00:05:43 |
Crypt-Passphrase-Bcrypt-Compat | LEONT | A bcrypt encoder for Crypt::Passphrase | 2024-04-08T14:24:10 |
DBD-Mock-Session-GenerateFixtures | UXYZAB | When a real DBI database handle ($dbh) is provided, the module generates DBD::Mock::Session data. Otherwise, it returns a DBD::Mock::Session object populated with generated data. This not a part form DBD::Mock::Session distribution just a wrapper around it. | 2024-04-29T18:25:02 |
Data-Dumper-UnDumper | BIGPRESH | load Data::Dumper output, including self-references | 2024-04-25T21:42:30 |
Data-MiniDumpX | PERLANCAR | A simplistic data structure dumper (demo for Plugin::System) | 2024-04-14T00:06:13 |
DateTime-Format-PDF | SKIM | PDF DateTime Parser and Formatter. | 2024-04-01T09:23:07 |
Devel-Confess-Patch-UseDataDumpHTMLCollapsible | PERLANCAR | Use Data::Dump::HTML::Collapsible to stringify reference | 2024-04-26T00:05:16 |
Devel-Confess-Patch-UseDataDumpHTMLPopUp | PERLANCAR | Use Data::Dump::HTML::PopUp to stringify reference | 2024-04-28T00:06:05 |
Dist-Build | LEONT | A modern module builder, author tools not included! | 2024-04-26T10:50:10 |
Dist-Zilla-Plugin-DistBuild | LEONT | Build a Build.PL that uses Dist::Build | 2024-04-26T10:55:35 |
Dist-Zilla-Plugin-DynamicPrereqs-Meta | LEONT | Add dynamic prereqs to to the metadata in our Dist::Zilla build | 2024-04-27T15:50:03 |
ExtUtils-Builder | LEONT | An overview of the foundations of the ExtUtils::Builder Plan framework | 2024-04-25T12:14:45 |
ExtUtils-Builder-Compiler | LEONT | Portable compilation | 2024-04-25T13:18:11 |
JSON-Ordered-Conditional | LNATION | A conditional language within an ordered JSON struct | 2024-04-06T06:47:37 |
JSON-ToHTML | ARISTOTLE | render JSON-based Perl datastructures as HTML tables | 2024-04-09T04:28:11 |
Knowledge | RSPIER | a great new dist | 2024-04-27T11:13:53 |
Log-Any-Simple | MATHIAS | A very thin wrapper around Log::Any, using a functional interface that dies automatically when you log above a given level. | 2024-04-24T19:51:03 |
Mo-utils-Country | SKIM | Mo country utilities. | 2024-04-11T13:41:33 |
Mo-utils-Time | SKIM | Mo time utilities. | 2024-04-12T14:28:06 |
Mo-utils-TimeZone | SKIM | Mo timezone utilities. | 2024-04-03T16:34:52 |
Mojolicious-Plugin-Authentication-OIDC | TYRRMINAL | OpenID Connect implementation integrated into Mojolicious | 2024-04-25T19:27:09 |
Mojolicious-Plugin-Cron-Scheduler | TYRRMINAL | Mojolicious Plugin that wraps Mojolicious::Plugin::Cron for job configurability | 2024-04-16T11:48:54 |
Mojolicious-Plugin-Migration-Sqitch | TYRRMINAL | Run Sqitch database migrations from a Mojo app | 2024-04-30T15:37:52 |
Mojolicious-Plugin-Module-Loader | TYRRMINAL | Automatically load mojolicious namespaces | 2024-04-19T14:09:36 |
Mojolicious-Plugin-ORM-DBIx | TYRRMINAL | Easily load and access DBIx::Class functionality in Mojolicious apps | 2024-04-03T13:32:06 |
Mojolicious-Plugin-SendEmail | TYRRMINAL | Easily send emails from Mojolicious applications | 2024-04-01T20:40:24 |
Mojolicious-Plugin-Sessionless | TYRRMINAL | Installs noop handlers to disable Mojolicious sessions | 2024-04-16T12:45:37 |
MooX-Pack | LNATION | The great new MooX::Pack! | 2024-04-20T01:52:17 |
Net-Async-OpenExchRates | VNEALV | Interaction with OpenExchangeRates API | 2024-04-20T11:46:28 |
Net-EPP-Server | GBROWN | A simple EPP server implementation. | 2024-04-08T09:38:21 |
Number-Iterator | LNATION | The great new Number::Iterator! | 2024-04-18T19:45:31 |
Parallel-TaskExecutor | MATHIAS | Cross-platform executor for parallel tasks executed in forked processes | 2024-04-13T20:02:27 |
Plack-App-Login-Request | SKIM | Plack application for request of login information. | 2024-04-29T14:23:02 |
Sah-SchemaBundle-Business-ID-BCA | PERLANCAR | Sah schemas related to BCA (Bank Central Asia) bank | 2024-04-23T00:05:53 |
Sah-SchemaBundle-Business-ID-Mandiri | PERLANCAR | Sah schemas related to Mandiri bank | 2024-04-30T00:05:43 |
Sah-SchemaBundle-Comparer | PERLANCAR | Sah schemas related to Comparer | 2024-04-21T00:05:30 |
Sah-SchemaBundle-Path | PERLANCAR | Schemas related to filesystem path | 2024-04-01T00:06:15 |
Sah-SchemaBundle-Perl | PERLANCAR | Sah schemas related to Perl | 2024-04-02T00:05:40 |
Sah-SchemaBundle-SortKey | PERLANCAR | Sah schemas related to SortKey | 2024-04-22T00:06:02 |
Sah-SchemaBundle-Sorter | PERLANCAR | Sah schemas related to Sorter | 2024-04-03T00:14:57 |
Sah-Schemas-Sorter | PERLANCAR | Sah schemas related to Sorter | 2024-04-03T00:05:43 |
Seven | LNATION | The great new Seven! | 2024-04-13T03:30:11 |
Sort-Key-SortKey | PERLANCAR | Thin wrapper for Sort::Key to easily use SortKey::* | 2024-04-04T00:05:05 |
SortExample-Color-Rainbow-EN | PERLANCAR | Ordered list of names of colors in the rainbow, in English | 2024-04-05T00:06:12 |
SortKey-Num-pattern_count | PERLANCAR | Number of occurrences of string/regexp pattern as sort key | 2024-04-06T00:05:41 |
SortKey-Num-similarity | PERLANCAR | Similarity to a reference string as sort key | 2024-04-08T00:05:21 |
SortKey-date_in_text | PERLANCAR | Date found in text as sort key | 2024-04-19T00:05:23 |
SortSpec | PERLANCAR | Specification of sort specification | 2024-04-09T00:05:37 |
SortSpec-Perl-CPAN-ChangesGroup-PERLANCAR | PERLANCAR | Specification to sort changes group heading PERLANCAR-style | 2024-04-10T00:05:24 |
Sorter-from_comparer | PERLANCAR | Sort by comparer generated by a Comparer:: module | 2024-04-11T00:05:17 |
Sorter-from_sortkey | PERLANCAR | Sort by keys generated by a SortKey:: module | 2024-04-12T00:05:58 |
Sqids | MYSOCIETY | generate short unique identifiers from numbers | 2024-04-06T10:43:27 |
TableData-Business-ID-BPOM-FoodAdditive | PERLANCAR | Food additives in BPOM | 2024-04-10T11:10:00 |
Tags-HTML-Image | SKIM | Tags helper class for image presentation. | 2024-04-20T13:32:39 |
Tags-HTML-Login-Request | SKIM | Tags helper for login request. | 2024-04-29T11:23:37 |
Test2-Tools-MIDI | JMATES | test MIDI file contents | 2024-04-09T23:42:34 |
Tiny-Prof | TIMKA | Perl profiling made simple to use. | 2024-04-26T07:19:38 |
Web-Async | TEAM | Future-based web+HTTP handling | 2024-04-23T16:50:24 |
YAML-Ordered-Conditional | LNATION | A conditional language within an ordered YAML struct | 2024-04-06T06:05:51 |
kraken | PHILIPPE | api.kraken.com connector | 2024-04-05T09:11:35 |
papersway | SPWHITTON | PaperWM-like window management for Sway/i3wm | 2024-04-12T07:52:39 |
Number of new CPAN distributions this period: 81
Number of authors releasing new CPAN distributions this period: 26
Authors by number of new CPAN distributions this period:
No | Author | Distributions |
---|---|---|
1 | PERLANCAR | 30 |
2 | TYRRMINAL | 7 |
3 | LEONT | 7 |
4 | SKIM | 7 |
5 | LNATION | 5 |
6 | MATHIAS | 2 |
7 | SPWHITTON | 2 |
8 | DJERIUS | 2 |
9 | ARISTOTLE | 2 |
10 | PHILIPPE | 1 |
11 | JFORGET | 1 |
12 | VNEALV | 1 |
13 | RSPIER | 1 |
14 | UXYZAB | 1 |
15 | WATERKIP | 1 |
16 | GBROWN | 1 |
17 | CORION | 1 |
18 | EGOR | 1 |
19 | TIMKA | 1 |
20 | TEAM | 1 |
21 | BIGPRESH | 1 |
22 | HIGHTOWE | 1 |
23 | DAMI | 1 |
24 | MYSOCIETY | 1 |
25 | JMATES | 1 |
26 | GDT | 1 |
Welcome to “What’s new on CPAN”, a curated look at last month’s new CPAN uploads for your reading and programming pleasure. Enjoy!
Published by Ted James on Monday 29 April 2024 07:12
Published by Unknown on Sunday 28 April 2024 09:07
Published by Unknown on Sunday 28 April 2024 09:05
This is the weekly favourites list of CPAN distributions. Votes count: 75
Week's winner (+4): App::perlimports
Build date: 2024/04/28 07:04:22 GMT
Clicked for first time:
Increasing its reputation:
Published by Amber Krawczyk on Saturday 27 April 2024 11:36
We hope you are coming to [The Perl and Raku Conference[(https://tprc.us/) in Las Vegas June 24-28! Plans are underway for a wonderful TPRC. But a conference of this type is only possible because of volunteers who give their time and expertise to plan, promote, and execute every detail. We need volunteers! You may have already volunteered to speak at the conference; if so, wonderful! If you are not presenting (or even if you are), there are many ways to help. We need people to set up and take down, to run the registration desk, to serve as room monitors, to help record the talks, and to just be extra hands. If you can spare some of your time for the sake of the conference, please fill out a volunteer form at https://tprc.us/tprc-2024-las/volunteer/ . We also welcome spouses and friends of attendees who might be coming along to Las Vegas to share the experience. We are offering TPRC "companion" tickets, for access to the social parts of the conference (food, drink, parties) but not the technical. Volunteers of at least one complete day, who sign up before the conference, will have companion access "comped". If you have questions about volunteering, please contact our TPRC Volunteer Coordinator: Sarah Gray sarah.gray@pobox.com
Published by Saif Ahmed on Friday 26 April 2024 15:18
Another Grant Application from a key Raku develoer, Stefan Seifert. A member of the Raku Steering Council, Stefan is also an author of several Perl 5 modules including Inline::Python and (of course) Inline::Perl6. This Grant is to help advance AST or Abstract Syntax Tree. This is integral to Raku internals and allows designing and implementation of new language components, that can be converted into bytecode for execution by the interpreteter or "virtual machine" more easily that trying to rewrite the interpretter. Here is an excellent intro by Elizabeth Mattijsen
There is a grant called RakuAST granted to Johnathan Worthington that is still listed as running. Sadly Johnathan has moved on and is no longer actively developing the Rakudo core. However the goal of his grant is still worthy as it is one of the strategic initiatives providing numerous benefits to the language. I have in fact already taken over his work on RakuAST and over the last two years have pushed some 450+ commits which led to hundreds of spectests to pass. This work was done in my spare time which was possible because I had a good and reliable source of income and could at times sneak in some Raku work into my dayjob. I can no longer claim that Raku is in any way connected to my day job and time invested in Raku comes directly out of the pool that should ensure my financial future. In other words, there's a real cost for me and I'd like to ask for this to be offset by way of a grant.
This is mostly directly taken from the RakuAST grant proposal as the goal stays the same:
An AST can be thought of as a document object model for a programming language. The goal of RakuAST is to provide an AST that is part of the Raku language specification, and thus can be relied upon by the language user. Such an AST is a prerequisite for a useful implementation of macros that actually solve practical problems, but also offers further powerful opportunities for the module developer. For example:
RakuAST will also become the initial internal representation of Raku programs used by Rakudo itself. That in turn gives an opportunity to improve the compiler. The frontend compiler architecture of Rakudo has changed little in the last 10 years. Naturally, those working on it have learned a few things in that time, and implementing RakuAST provides a chance to fold those learnings into the compiler. Better static optimization, use of parallel processing in the compiler, and improvements to memory and time efficiency are all quite reasonable expectations. We have already seen that the better internal structure fixes a few long standing bugs incidentally. However, before many of those benefits can be realized, the work of designing and implementing RakuAST, such that the object model covers the entire semantic and declarational space of the language, must take place. This grant focuses on that work.
Considering the amount of work these items already will be, I would specifically exclude work targeted at synthetic AST generation, designs for new macros based on this AST, and anything else that is not strictly necessary to reach the goal of the RakuAST compiler frontend becoming the default.
For the test and spectest suites I would continue my tried and proven model of picking the next failing test file and making fixes until it passes. Based on current velocity this will take around 6 months. However there's hope that some community members will return from their side projects and chime in.
$10,000 for an estimated 200 hours of work.
I have been involved in Rakudo development since 2014 when I started development of Inline::Perl5 which brings full two-way interoperability between Raku and Perl. Since then I have helped with every major effort in Rakudo core development like the Great List Refactor, the new dispatch mechanism and full support for unsigned native integers. I have fixed hundreds of bugs in MoarVM including garbage collection issues, race conditions and bugs in the specializer. I have made NativeCall several orders of magnitude faster by writing a special dispatcher and support for JIT compiling native calls. I replaced a slow and memory hungry MAST step in the compilation process by writing bytecode directly, have written most of Rakudo's module loading and repository management code and in general have done everything I could to make Rakudo production worthy. I have also been a member of the Raku Steering Council since its inception.
Elizabeth Mattijsen, Geoffrey Broadwell, Nick Logan, Richard Hainsworth
At the Koha Hackfest I had several discussions with various colleagues about how to improve the way plugins and hooks are implemented in Koha. I have worked with and implemented various different systems in my ~25 years of Perl, so I have some opinions on this topic.
When you have some generic piece of code (eg a framework or a big application that will be used by different user groups (like Koha)), people will want to add custom logic to it. But this custom logic will probably not make sense to every user. And you probably don't want all of these weird adaptions in the core code. So you allow users to write their weird adaptions in Plugins, which will be called via Hooks in the core code base. This patter is used by a lot of software, from eg mod_perl/Apache, Media Players to JavaScript frontend frameworks like Vue.
Generally, there are two kinds of Hook philosophies: Explicit Hooks, where you add explicit calls to the hook to the core code; and Implicit Hooks, where some magic is used to call Plugins.
Explicit Hooks are rather easy to understand and implement:
package MyApp::Model::SomeThing;
method create ($args) {
$self->call_hook("pre_create", $args);
my $item = $self->resultset("SomeThing")->create( $args );
$self->call_hook("post_create", $args, $item);
return $item;
}
So you have a method create
which takes some $args
. It first calls the pre_create
hook, which could munge the $args
. Then it does what the Core implementation wants to do (in this case, create a new item in the database). After that it calls the post_create
hook which could do further stuff, but now also has the freshly created database row available.
The big advantage of explicit hooks is that you can immediately see which hook is called when & where. The downside is of course that you have to pepper your code with a lot of explicit calls, which can be very verbose, especially once you add error handling and maybe a way for the hook to tell the core code to abort processing etc. Our nice, compact and easy to understand Perl code will end up looking like Go code (where you have to do error handling after each function call)
Implicit hooks are a bit more magic, because the usually do not need any adaptions to the core code:
package MyApp::Model::SomeThing;
method create ($args) {
my $item = $self->resultset("Foo")->create( $args );
return $item
}
There are lots of ways to implement the magic needed.
One well-known one is Object Orientation, where you can "just" provide a subclass which overrides the default method. Of course you will then have to re-implement the whole core method in your subclass, and figure out a way to tell the core system that it should actually use your subclass instead of the default one.
Moose allows for more fine-grained ways to override methods with it's method modifiers like before
, after
and around
. If you also add Roles to the mix (or got all in with Parametric Roles) you can build some very abstract base classes (similar to Interfaces in other languages) and leave the actual implementation as an exercise to the user...
Coincidentally, at the German Perl Workshop Ralf Schwab presented how they used AUTOLOAD
and a hierarchy of shadow classes to add a Plugin/Hook system to their Cosmo web shop (which seems to be also wildly installed and around for quite some time). (I haven't seen the talk, only the slides
I have some memories (not sure if fond or nightmarish) of a system I build between 1998 and 2004 which (ab)used the free access Perl provides to the symbol table to use some config data to dynamically generate classes, which could then later by subclassed for even more customization.
But whatever you use to implement them, the big disadvantage of Implicit Hooks is that it is rather hard to figure out when & why each piece of code is called. But to actually and properly use implicit hooks, you will also have to properly structure your code in your core classes into many small methods instead of big 100-line monsters, which also improves testabilty.
Generally, "it depends". But for Koha I think Explicit Hooks are better:
next
or SUPER
) might be a bit to much for some Plugin authors (who might be more on the librarian-who-can-code-a-bit side of the spectrum then on dev-who-happens-to-work-with-libraries)boring > magic
!Using implicit hooks could maybe make sense if Koha
around
in Moose, error handling, ...).An while it itches me in the fingers to do come up with such a smart system, I think currently dev time is better spend on other issues and improvements.
P.S.: I'm currently traveling trough Albania, so I might be slow to reply to any feedback.
Published on Friday 19 April 2024 07:00
Last week we (aka HKS3) attended the Koha Hackfest in Marseille, hosted by BibLibre. The hackfest is a yearly meeting of Koha developers and other interested parties, taking place since ~10 years in Marseille. For me, it was the first time!
git-bz
.--dbshell
to KTD for easy access to the DB shell.Thanks to BibLibre and Paul Poulain for organizing the event, and to all the attendees for making it such a wonderful 4 days!